<!-- Teacher_StudyCourseListWindow.html -->
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
		<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
		<title>教师端课程列表</title>
		<link rel="stylesheet" href="../../css/base.css">
		<link rel="stylesheet" href="../../css/CFNetPP_Base.css">
		<style type="text/css">
			.nav-right-img {
				width: 24px;
				margin-left: 12px;
				margin-top: 8px;
			}
			.nav-right-scan-img {
				width: 20px;
				margin-left: 14px;
				margin-top: 12px;
			}
			.redPointMessage {
				width: 8px;
				height: 8px;
				top: 4px;
				left: 30px;
				right: 0px;
			}
		</style>
	</head>
	<body>
		<div class="base_style_color " id='BarAppearance' style="height: 22px;width: 100%"></div>
		<div class="base_navigation_bar base_style_color base_navigation_item_bar">
			<a class="base_left_item" href="#" onclick="backClick()"> <img class="base_back_icon" src="../../image/icon_jiantou.png" alt=""> </a>
			<span>授课</span>
		<!--	<a class="base_right_item" onclick="toMessageClick()" style="position:relative;" > <div id="redPointMessage" class="redPointMessage"></div> <img id="msg_img" class="nav-right-img" src="../../image/icon_msg_message.png" alt=""> </a>-->
			<!--<a class="base_right_item" onclick="toScanClick()" style="position:relative;" >
			<img id="scan_img" class="nav-right-scan-img" src="../../image/icon_scan.png" alt="">
			</a>-->
		</div>
	</body>
	<script type="text/javascript" src="../../script/api.js"></script>
	<script type="text/javascript" src="../../script/jquery.min.js"></script>
	<script type="text/javascript" src="../../script/MD5.js"></script>
	<script type="text/javascript" src="../../script/requestTool.js"></script>
	<script type="text/javascript" src="../../script/push.js"></script>
	<script type="text/javascript">
		apiready = function() {
			setupSubframe();
			api.addEventListener({
				name : 'showTeachCourseFrameNotifi'
			}, function(ret, err) {
				showTeachCourseFrame();
			});
			api.addEventListener({
				name : 'hideTeachCourseFrameNotifi'
			}, function(ret, err) {
				hideTeachCourseFrame();
			});
//			setupMsgBtnStatus();
			api.addEventListener({
				name : 'viewappear'
			}, function(ret, err) {
				setupMsgBtnStatus();
			});
			api.addEventListener({
				name : 'pushMessage'
			}, function(ret, err) {
				pushMessage();
			});
		}
		//push 消息提醒
		function pushMessage() {
			var jid = $api.getStorage('cfnetppjxid');
			var msgVal = $api.getStorage('cfnetppmessagejiaoxue' + jid);
			console.log("msgVal : " + msgVal);
			if (msgVal == 1) {
				$('#redPointMessage').show();
			} else {
				$('#redPointMessage').hide();
			}
		}

		function setupMsgBtnStatus() {
			api.sendEvent({
				name : 'click_pushMessage_index'
			});
//			pushMessage();
			// var params = {
			//     uid : $api.getStorage('cfnetppuid'),
			//     jid : $api.getStorage('cfnetppjxid')
			// };
			// cfnetppPOST(url_toDoMessage, params, false, function(data, status){
			//     if (status == 'success') {
			//         if (data.code == 200) {//有新的消息
			//             $('#msg_img').attr('src', '../../image/icon_msg_message_new.png');
			//         }else{
			//             $('#msg_img').attr('src', '../../image/icon_msg_message.png');
			//         }
			//     }
			// });
		}

		function setupSubframe() {
			sendBuriedNotifi(0, '课程列表', '006');
			var y = $('#BarAppearance').height() + $('.base_navigation_bar').height();
			var h = api.winHeight - y;
			// if ($api.getStorage('cfnetppjxid') == 333) {
				h -= 52;
			// }
			api.openFrame({
				name : 'Teacher_StudyCourseList',
				url : 'Teacher_StudyCourseList.html',
				rect : {
					x : 0,
					y : y,
					w : 'auto',
					h : h
				},
				pageParam : {
					sourceurl : window.location.pathname,
					sourcetitle : document.title,
				},
				bounces : false
			});
		}

		function sendBuriedNotifi(busionessid, pagetype, pagetypeid) {
			var userinfo = {
				uid : $api.getStorage('cfnetppuid'),
				jid : $api.getStorage('cfnetppjxid'),
				uname : $api.getStorage('cfnetppusername'),
			}
			var data = {
				busionessid : busionessid,
				pagetype : pagetype,
				pagetypeid : pagetypeid,
				sourceurl : api.pageParam.sourceurl,
				sourcetitle : api.pageParam.sourcetitle,
				accesspageurl : window.location.pathname,
				accesspagetitle : document.title,
				userinfo : userinfo
			}
			SendBehaviorTrajectoriesNotifi_Study(data);
		}

		function showTeachCourseFrame() {
			api.setFrameAttr({
				name : 'Teacher_StudyCourseList',
				hidden : false
			});
		}

		function hideTeachCourseFrame() {
			api.setFrameAttr({
				name : 'Teacher_StudyCourseList',
				hidden : true
			});
		}

		function backClick() {
			api.closeWin();
			sendBuriedNotifi(1, '课程列表', '006');
		}

		function toMessageClick() {
			sendBuriedNotifi(1, '课程列表', '006');
			api.openWin({useWKWebView:true,
				name : 'Teacher_ToDoMessageWin',
				url : 'Teacher_ToDoMessageWin.html',
				pageParam : {
					sourceurl : window.location.pathname,
					sourcetitle : document.title,
				},
			});
		}

		function toScanClick() {
			var systemType = api.systemType;
			if (systemType == 'ios') {
				return;
			}
			var Scan = api.require('Scan');
			var param = {
				name : "111"
			};
			Scan.showScan(param, function(ret, err) {
				console.log("data : " + JSON.stringify(ret));
				var url = eval('(' + ret.result + ')').url;
				if (url != undefined && checkURL(url)) {
					var title = eval('(' + ret.result + ')').title;
					console.log("data url : " + url);
					var pageParam = {
						url : url,
						title : title,
						shareurl :url
					};
					api.openWin({useWKWebView:true,
						name : 'indexLunDetailsWindow',
						url : '../HomePage/indexLunDetailsWindow.html',
						pageParam : pageParam
					});
				}
			});
		}

		function checkURL(URL) {
			var str = URL;
			//判断URL地址的正则表达式为:http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?
			//下面的代码中应用了转义字符"\"输出一个字符"/"
			var Expression = /http(s)?:\/\/([\w-]+\.)+[\w-]+(\/[\w- .\/?%&=]*)?/;
			var objExp = new RegExp(Expression);
			if (objExp.test(str) == true) {
				return true;
			} else {
				return false;
			}
		}
	</script>
</html>